//
//  AdvancedTableVc.m
//  Courses
//
//  Created by xxx on 15/1/6.
//  Copyright (c) 2015年 wtf. All rights reserved.
//

#import "AdvancedTableVc.h"
#import "AdvancedCell.h"

#import "AdvancedDetailsVc.h"
#import "CoursesViewController.h"

#import "PublicCourse.h"

@implementation AdvancedTableVc

SYNTHESIZE_SINGLETON_FOR_IMPL(AdvancedTableVc)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AdvancedCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell)
    {
        cell = [[AdvancedCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    
    if (self.items.count > indexPath.row)
    {
        cell.course = self.items[indexPath.row];
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}

- (NSArray *)fetchedItems
{
    return [AdvancedCourse getVipCoursesWithSortOption:self.sortOption teacherId:self.teacherId tagId:self.tagId pageNo:self.pageNo];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.items.count > indexPath.row)
    {
        AdvancedDetailsVc *vc = [[AdvancedDetailsVc alloc] init];
        vc.course = self.items[indexPath.row];
        vc.hidesBottomBarWhenPushed = YES;
//        [self.masterVc.navigationController pushViewController:vc animated:YES];
        [[CoursesViewController sharedInstance].navigationController pushViewController:vc animated:YES];
    }
}

@end
